<template>
    <van-swipe :autoplay="3000" lazy-render>
        <van-swipe-item v-for="(item, index) in store.bannerList.list" :key="index">
            <!-- <a :href="item.url"target="_blank" v-if="item.url">
                <img :src="item.picture" />
            </a>
            <img :src="item.picture" v-else="item.url"/> -->
            <img :src="item.picture" />
        </van-swipe-item>
    </van-swipe>
</template>

<script setup lang="ts">
import { bannerListAPI } from "@/api/task";
import { taskStore } from '@/store/task'
import { Toast } from 'vant';

    const store = taskStore()
    // 获取Banner列表
    const getBannerList = async() => {
        const res = await bannerListAPI(2)
        if (res) {
            store.setbannerList(res)
        }else{
            Toast('图片加载失败')
        }
       
    }
    //store里面的bannerList没有数据 执行Banner列表
    if (store.bannerList.length <= 0)  getBannerList()
</script>

<style scoped>
img {
    width: 100%;
    height: 7.47rem;
    border-radius: 0.5rem;
}
>>> .van-swipe__indicator{
    display: none;
}
>>> .van-swipe__track {
    height: 7.47rem;
}
</style>